<?php
namespace XWAM\Addon\PXCallSystem\Controller;
/**
 * 通话记录控制器
 *
 * @since 1.0 2015-1-1 by sutroon
 */
class ApiCallRecordController extends \Think\Controller {

    // 座席来电弹屏 2014-12-16 by sutroon
    public function seat_screen_popup() {
        $extension = I('exten');
        if (!$extension) {
            die('');
        }
        $memcache = new \Memcache;
        $memcache->connect('localhost', 11211);
        $lineNum = $memcache->get($extension);
        $memcache->delete($extension);
        $memcache->close();
        $data = array('extension' => $extension, 'lineNum' => $lineNum);
        echo 'extension_screen_popup_jsonp(' . json_encode($data) . ')';
    }

    // 座席获取最近10条通话记录 2014-12-16 by sutroon
    public function seat_get_callrecord_list() {
        $extension = I('exten');
        if (!$extension) {
            die('');
        }
        $cdrlist = M('cdr')->field('callerNo as lineNum,xcallAnswer as createdTime')->where("extension='$extension' and direction=1")->order('id desc')->limit(10)->select();
        echo 'extension_callrecord_list_jsonp(' . json_encode($cdrlist) . ')';    
    }

}
